package com.ayit.car.service.impl;

import com.ayit.car.common.result.PageResult;
import com.ayit.car.pojo.dto.BrandPageQueryDTO;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ayit.car.pojo.Brands;
import com.ayit.car.service.BrandsService;
import com.ayit.car.mapper.BrandsMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 为王下葬
* @description 针对表【brands(汽车品牌表)】的数据库操作Service实现
* @createDate 2024-06-24 18:12:48
*/
@Service
public class BrandsServiceImpl extends ServiceImpl<BrandsMapper, Brands>
    implements BrandsService{

    @Autowired
    private BrandsService brandsService;
    @Autowired
    private BrandsMapper brandsMapper;


    /**
     * 分页查询
     * @param brandPageQueryDTO
     * @return
     */
    @Override
    public PageResult pageQuery(BrandPageQueryDTO brandPageQueryDTO) {
        PageHelper.startPage(brandPageQueryDTO.getPage(), brandPageQueryDTO.getPageSize());

        Page<Brands> page = brandsMapper.pageQuery2(brandPageQueryDTO);
        List<Brands> brandsList = page.getResult();
        return new PageResult(page.getTotal(), brandsList);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Override
    public Brands selectBrandsById(Long id) {
        Brands brands = brandsMapper.selectById(id);
        return brands;
    }

    /**
     * 添加
     * @param brands
     */
    @Override
    public void insertBrands(Brands brands) {
        brandsMapper.insert(brands);
    }

    /**
     * 修改
     * @param brands
     */
    @Override
    public void updateBrands(Brands brands) {
        brandsMapper.updateById(brands);
    }

    /**
     * 删除
     * @param ids
     */
    @Override
    public void deleteBrandsByIds(List<Long> ids) {
        brandsMapper.deleteBatchIds(ids);
    }
}




